/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package gui;
import javax.swing.*;
import java.awt.*;
import java.awt.image.*;

/**
 *
 * @author dario
 */
public class ShowFrame extends JFrame
{
    ShowPanel panel = null;
    
    public ShowFrame()
    {
        setSize(300,300);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        getContentPane().add((panel=new ShowPanel()));
    }
    
    public void setImage(BufferedImage img)
    {
        panel.img = img;
        panel.paintImmediately(0, 0, img.getWidth(), img.getHeight());
        this.setSize(img.getWidth(), img.getHeight()+30);
        this.repaint();
        
    }
}


class ShowPanel extends JPanel
{
    BufferedImage img = null;
    
    public void paintComponent(Graphics g)
    {
        super.paintComponent(g);
        
        if(img!=null)
            g.drawImage(img, 0, 0, null);
    }
}
